﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using StackExchange.Redis;

namespace WebApp.Services
{
    public class RedisCacheService : ICacheService
    {
        private readonly ConnectionMultiplexer _connectionMultiplexer;

        public RedisCacheService(DbConnectionConfigurationServicecs dbConfig)
        {
            _connectionMultiplexer = ConnectionMultiplexer.Connect(dbConfig.DbConnection.Redis);
        }

        public bool Add(string key, object value)
        {
            var db = _connectionMultiplexer.GetDatabase();
            return db.StringSet(key, value.ToString());
        }

        public object Get(string key)
        {
            var db = _connectionMultiplexer.GetDatabase();
            return db.StringGet(key);

        }
    }
}
